package com.origin.src;

import com.origin.src.aspect.XAspectJA;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Component;


@Lazy
@Component
@DependsOn({"XBeanB", "XBeanC"})
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
@PropertySource("/application.properties")
public class XBeanA {


    public XBeanA() {
        System.out.println("BeanA的构造方法");
    }


    @Autowired
            @Lazy
    XBeanC XBeanC;

//    @Autowired
//    XMyBatis XMyBatis;

    XConfiguration.XBeanB XBeanB;

    @Bean
    public XConfiguration.XBeanB XBeanB() {
        return new XConfiguration.XBeanB();
    }

    public XConfiguration.XBeanB getXBeanB() {
        return XBeanB;
    }

    public void setXBeanB(XConfiguration.XBeanB XBeanB) {
        this.XBeanB = XBeanB;
    }

    @Value("spring.application.name")
    String springApplicationName;

    @XAspectJA
    public String toS() {
        return "XBeanA{}";
    }

    @XAspectJA
    public String to(boolean f) {
        if (f) {
            return ((XBeanA) AopContext.currentProxy()).toS();
        }
        return toS();
    }


}
